package cn.bdqn.controller;

import cn.bdqn.entity.City;
import cn.bdqn.service.CityService;
import org.springframework.http.ResponseEntity;
import org.springframework.web.bind.annotation.*;
import java.util.List;
import javax.annotation.Resource;

@RestController
@RequestMapping("city")
public class CityController {
    @Resource
    private CityService cityService;
    
    @GetMapping
    public ResponseEntity<List<City>> queryAll() {
        return ResponseEntity.ok(this.cityService.queryAll());
    }

    @GetMapping("{id}")
    public ResponseEntity<City> queryById(@PathVariable("id") Integer id) {
        return ResponseEntity.ok(this.cityService.queryById(id));
    }

    @PostMapping
    public ResponseEntity<City> add(City city) {
        return ResponseEntity.ok(this.cityService.insert(city));
    }

    @PutMapping
    public ResponseEntity<City> edit(City city) {
        return ResponseEntity.ok(this.cityService.update(city));
    }
    @DeleteMapping
    public ResponseEntity<Boolean> deleteById(Integer id) {
        return ResponseEntity.ok(this.cityService.deleteById(id));
    }

}

